Maximum Count of Positives or Negatives
Medium
Question
Given a sorted list of integers, return the maximum count between the number of negative integers and number of positive integers in the list.
Remember, 0 is neither negative nor positive.
Note: Solve this problem in O(logn) time.
Input: [-3, 0, 0, 5, 6, 8]
Output: 3
There is 1 negative integer and 3 positive integers. The maximum count is 3.
Input: [-3, -2, -2, -1, 4, 5]
Output: 4
There is 4 negative integers and 2 positive integers. The maximum count is 4.
Input: [8]
Output: 1
There is 1 positive integer and 0 negative integers. The maximum count is 1.
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
What is the maximum count of positive or negative integers for this given list? [-7, -5, -3, -1, -1, 0, 2, 4, 4, 6]
3
4
5
6
All test cases pass! 🎉
Time limit exceeded
InputExpected OutputActual Output
Standard OutputScroll down...
Login or signup to save your code.
Uh oh... looks like you don't yet have access.
Not sure what this unlocks? Check out a free pattern section.